// run: $exec < input
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

int const maxn = 200;
int f[maxn][maxn];

std::string s1, s2;

int main()
{
	std::cin >> s1 >> s2;
	int l1 = s1.size();
	int l2 = s2.size();
	bool automaton = false;
	bool array = false;
	if (l1 > l2) {
		for (int i = 1; i <= l1; i++) {
			for (int j = 1; j <= l2; j++) {
				f[i][j] = f[i - 1][j];
				if (s1[i - 1] == s2[j - 1])
					f[i][j] = std::max(f[i][j], f[i - 1][j - 1] + 1);
				if (f[i][j] == std::min(l1, l2)) {
					automaton = true;
					break;
				}
			}
			if (automaton) break;
		}
	}

	std::sort(s1.begin(), s1.end());
	std::sort(s2.begin(), s2.end());
	if (l1 == l2) {
		array = (s1 == s2);
	} else if (l1 > l2 && !automaton) {
		std::map<char, int> all;
		for (int i = 0; i < l1; i++) all[s1[i]]++;
		int i = 0;
		for (; i < l2; i++)
			if (all[s2[i]] == 0) break;
			else all[s2[i]]--;
		if (i >= l2) automaton = array = true;
	}
	if (automaton && array)
		std::cout << "both\n";
	else if (array)
		std::cout << "array\n";
	else if (automaton)
		std::cout << "automaton\n";
	else
		std::cout << "need tree\n";
}

